##Figure 1-Top
setwd("C:\\Users\\kogan.18\\Box\\Monopsony\\")
dat<-read.csv("hh_county.csv")

library(stringr)
pdf("hh_county.pdf", height=4, width=6)
par(oma=c(0,0,0,0), mar=c(4.1,4.1,2,2))
plot(0,0, type="n", ylim=c(-0.1,0.4), xlim=c(0,1), ylab="Effect on Log(Average Teacher Salary)", xlab="Labor Market Concentration (HH Index)", ann=TRUE, axes=FALSE)
axis(1,at = seq(0,1, by = 0.1), label = seq(0,1, by = 0.1), cex.axis = 0.9)#add x-axis and labels; "pretty" creates a sequence of  equally spaced nice values that cover the range of the values in 'x'-- in this case, integers
axis(2, , cex.axis = 0.9)
box()
abline(h=0, lwd = .5, col = "black", lty="dashed")
segments(x0=0.05,y0=0, x1=0.15,y1=as.numeric(as.character(dat[2,2])),lwd=1.5)#draw lines connecting 95% confidence intervals
for(i in 0:7){
segments(x0=0.15+(i*0.1),y0=as.numeric(as.character(dat[2+(2*i),2])), x1=0.25+(i*0.1),y1=as.numeric(as.character(dat[4+(i*2),2])),lwd=1.5)#draw lines connecting 95% confidence intervals
}
points(y=0, x=0.05, pch=15, xpd=TRUE, cex=1, col="black", bg="white")
for(i in 0:8){
segments(x0=0.15+(i*0.1),y0=as.numeric(str_split_fixed(dat[3+(i*2),2],",",2))[1], x1=0.15+(i*0.1),y1=as.numeric(str_split_fixed(dat[3+(i*2),2],",",2))[2],col="gray")#draw lines connecting 95% confidence intervals
points(y=as.numeric(as.character(dat[2+(i*2),2])), x=0.15+(i*0.1), pch=15, xpd=TRUE, cex=1, col="black", bg="white")
}
dev.off()



##Figure 1-Bottom
setwd("C:\\Users\\kogan.18\\Box\\Monopsony\\")
dat<-read.csv("hh_district.csv")

library(stringr)
pdf("hh_district.pdf", height=4, width=6)
par(oma=c(0,0,0,0), mar=c(4.1,4.1,2,2))
plot(0,0, type="n", ylim=c(-0.05,0.15), xlim=c(0,1), ylab="Effect on Log(Average Teacher Salary)", xlab="Labor Market Concentration (HH Index)", ann=TRUE, axes=FALSE)
axis(1,at = seq(0,1, by = 0.1), label = seq(0,1, by = 0.1), cex.axis = 0.9)#add x-axis and labels; "pretty" creates a sequence of  equally spaced nice values that cover the range of the values in 'x'-- in this case, integers
axis(2, , cex.axis = 0.9)
box()
abline(h=0, lwd = .5, col = "black", lty="dashed")
segments(x0=0.05,y0=0, x1=0.15,y1=as.numeric(as.character(dat[2,2])),lwd=1.5)#draw lines connecting 95% confidence intervals
for(i in 0:7){
segments(x0=0.15+(i*0.1),y0=as.numeric(as.character(dat[2+(2*i),2])), x1=0.25+(i*0.1),y1=as.numeric(as.character(dat[4+(i*2),2])),lwd=1.5)#draw lines connecting 95% confidence intervals
}
points(y=0, x=0.05, pch=15, xpd=TRUE, cex=1, col="black", bg="white")
for(i in 0:8){
segments(x0=0.15+(i*0.1),y0=as.numeric(str_split_fixed(dat[3+(i*2),2],",",2))[1], x1=0.15+(i*0.1),y1=as.numeric(str_split_fixed(dat[3+(i*2),2],",",2))[2],col="gray")#draw lines connecting 95% confidence intervals
points(y=as.numeric(as.character(dat[2+(i*2),2])), x=0.15+(i*0.1), pch=15, xpd=TRUE, cex=1, col="black", bg="white")
}
dev.off()
